
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */
package itm.bo.productos;

//~--- non-JDK imports --------------------------------------------------------

import itm.conexion.SQLServerConection;

import itm.dao.productos.AtributosDAO;

import itm.exception.ControlException;

import itm.vo.prodructos.AtributosVO;

//~--- JDK imports ------------------------------------------------------------

import java.sql.Connection;
import java.sql.SQLException;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author BISA20
 */
public class AtributosBO {
    String             temp     = "";
    SQLServerConection conexion = new SQLServerConection();
    AtributosDAO       atributosDAO;
    Connection         dbConexion;

    public List<AtributosVO> consultarAtributos(AtributosVO atributosVO) throws ControlException {
        List<AtributosVO> listaAtributos = new ArrayList<AtributosVO>();

        try {
            dbConexion     = conexion.openConnection();
            atributosDAO   = new AtributosDAO(dbConexion);
            listaAtributos = atributosDAO.consultarAtributos(atributosVO);
        } catch (SQLException ex) {
            ex.getStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return listaAtributos;
    }

    public List<AtributosVO> consultarAtributosAnterio(AtributosVO atributosVO) throws ControlException {
        List<AtributosVO> listaAtributos = new ArrayList<AtributosVO>();

        try {
            dbConexion     = conexion.openConnection();
            atributosDAO   = new AtributosDAO(dbConexion);
            listaAtributos = atributosDAO.consultarAtributosAnteriores(atributosVO);
        } catch (SQLException ex) {
            ex.getStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return listaAtributos;
    }

    public List<AtributosVO> listaAtributos(AtributosVO atributosVO) throws ControlException {
        List<AtributosVO> listatribu = new ArrayList<AtributosVO>();

        try {
            dbConexion   = conexion.openConnection();
            atributosDAO = new AtributosDAO(dbConexion);
            listatribu   = atributosDAO.listarAtribu(atributosVO);
        } catch (SQLException ex) {
            ex.getStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return listatribu;
    }

    public String insetarAtributosProducto(AtributosVO atributosVO) throws Exception {
        String temp = "";

        try {
            dbConexion   = conexion.openConnection();
            atributosDAO = new AtributosDAO(dbConexion);
            temp         = atributosDAO.insertarAtributos(atributosVO);
        } catch (SQLException ce) {
            ce.printStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return temp;
    }

    public String modificarAtributosProducto(AtributosVO atributosVO) throws Exception {
        String temp = "";

        try {
            dbConexion   = conexion.openConnection();
            atributosDAO = new AtributosDAO(dbConexion);
            temp         = atributosDAO.modificarAtributos(atributosVO);
        } catch (SQLException ce) {
            ce.printStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return temp;
    }

    public String eliminarTipoEvento(AtributosVO atributosVO) throws ControlException {
        try {
            dbConexion   = conexion.openConnection();
            atributosDAO = new AtributosDAO(dbConexion);
            temp         = atributosDAO.eliminarAtributoProducto(atributosVO);
        } catch (SQLException ce) {
            ce.printStackTrace();
        } finally {
            conexion.closeConnection(dbConexion);
        }

        return temp;
    }
}
